/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package wf3.util;

import java.io.File;
import java.io.Serializable;
import jodd.mail.EmailAttachment;

/**
 *
 * @author romulogalindo
 */
public class Adjunto {

    private EmailAttachment attach;
    private String name;
    private String size;
    private String url;

    public Adjunto(EmailAttachment attach, String path) {
        this.attach = attach;
        this.size = this.attach.getSize() + " Kb";
        if (this.attach.getName() == null) {
            this.name = this.attach.getDataSource().getName();

        } else {
            this.name = this.attach.getName();
        }

        File file = new File(path + "/images/documentos_dia/" + this.name);
        this.attach.writeToFile(file);
        this.url = this.name;
    }
//
//    public EmailAttachment getAttach() {
//        return attach;
//    }
//
//    public void setAttach(EmailAttachment attach) {
//        this.attach = attach;
//    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Override
    public String toString() {
        return "[Adjunto: attach](name:" + getName() + ")(url:" + getUrl() + ")";
    }

}
